package com.yunfei.utils.procedure;

import com.yunfei.bo.smrz.HeGeTouZiZheRenZhengParamBo;
import com.yunfei.utils.string.StringUtil;
import oracle.jdbc.OracleTypes;
import org.springframework.transaction.annotation.Transactional;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @program: zntg_v2
 * @description:实名认证存储过程
 * @author: zhengyunfei
 * @create: 2018-12-03 17:02
 **/
public class HeGeTouZiZheRenZhengProcedure {
    /**
     PKG_YL_INTERFACE.sp_addqualifyinvestorreq
     输入参数（按顺序）：
     p_custno      in varchar2, --客户编号
     p_provetype  in varchar2, --证明类型(1资产证明 2收入证明)
     p_provebalance in number, --证明金额
     p_filegroupno  in number, --附件组编号  空
     p_fileno   in number,  --附件ID 空
     p_filename in varchar2,--附件名称多个附件以//拆分 默认空
     p_filepath in varchar2,--附件路径(绝对地址)默认空
     p_filesize in varchar2, --文件大小 默认空
     p_systemfrom  in varchar2, --来源系统 默认5:APP
     输出参数（按顺序）：
     returncode out varchar2, --处理结果 0:失败 1成功
     returninfo out varchar2 --结果描述 当处理结果为0时，输出错误描述 当处理结果为1时，输出对应附件输出编号
     **/
    @Transactional
    public ShiMingRenZhengProcedureReturnInfo save(HeGeTouZiZheRenZhengParamBo param, Connection conn){
        ShiMingRenZhengProcedureReturnInfo renZhengProcedureReturnInfo=null;
        //输入参数
        String custNo=param.getpCustno();
        String pProvetype=param.getpProvetype();//证明类型
        String pProvebalance=param.getpProvebalance();//证明类型
        //输出参数
        String pReasonCode;//处理结果:除1以外失败 1成功
        String pReasonInfo;//处理结果:结果描述
        String pReasonCode2;//处理结果:返回实名认证对应附件输出编号
        if(!StringUtil.isNullOrEmpty(custNo)){
            try {
                String sql = "call PKG_YL_INTERFACE.sp_addqualifyinvestorreq(?,?,?,?,?,?,?,?,?,?,?)";
                CallableStatement call = null;
                call = conn.prepareCall(sql);
                call.setString(1,custNo);
                call.setString(2,pProvetype);
                call.setString(3,pProvebalance);
                call.setString(4,"");
                call.setString(5,"");
                call.setString(6,"");
                call.setString(7,"");
                call.setString(8,"");
                call.setString(9,"5");//原系统 默认5 app
                call.registerOutParameter(10, OracleTypes.VARCHAR);
                call.registerOutParameter(11, OracleTypes.VARCHAR);
                call.execute();
                pReasonCode = call.getString(10);
                pReasonInfo = call.getString(11);
                renZhengProcedureReturnInfo=new ShiMingRenZhengProcedureReturnInfo();
                renZhengProcedureReturnInfo.setpReasonCode(pReasonCode);
                renZhengProcedureReturnInfo.setpReasonInfo(pReasonInfo);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return renZhengProcedureReturnInfo;
    }


}
